package com.ssy.lingxi.product.common.enums;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 导出商品表格列
 * @author jw.chen
 * @version 2.0.0
 * @date 2022/3/4
 */
public enum CommodityTableEnum {
    Name(1, "商品名称"),
    Code(2, "商品编码"),
    Brand(3, "商品品牌"),
    CustomerCategory(4, "会员品类"),
    Category(5, "平台后台品类"),
    Slogan(6, "商品标语"),
    SellingPoint(7, "商品卖点"),
    CommodityArea(8, "归属地市"),
    UnitName(9, "单位"),
    SubUnitName(10, "副单位"),
    MinOrder(11, "最小起订"),
    PriceType(12, "产品定价"),
    IsMemberPrice(13, "允许使用会员折扣价购买"),
    TaxRate(14, "税率"),
    Attribute(15, "规格属性"),
    Price(16, "价格"),
    PriceRate(17, "副单位单价换算比率");

    private final Integer code;
    private final String message;

    CommodityTableEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getClass(), this.code);
    }

    public static String getNameByCode(Integer code) {
        CommodityTableEnum typeEnum = Arrays.stream(CommodityTableEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
        return null == typeEnum ? "" : LanguageHolder.getName(CommodityTableEnum.class, typeEnum.getCode());
    }
}
